<?php 
if( !defined("OK") ) {
	die("hacking attacks!");
}


$objectID = $user->objrctID();
$tables = array();
$db = new DB();
if( $objectID != -1 ) {
	$sql = "SELECT 
			  `օbject_table`.`id`,
			  `օbject_table`.`table_number`,
			  `օbject_table`.`status_vip`,
			  `օbject_table`.`sits_count`,
			  `օbject_table`.`smoke`,
			  `օbject_table`.`status`,
			  `օbject_table`.`date_time`,
			  UNIX_TIMESTAMP() - UNIX_TIMESTAMP(`օbject_table`.`date_time`) AS `time`,
			  `օbject_table`.`name_{$LANG}` AS `name`,
			  IF(`օbject_table`.`status` = 0,'free','busy') AS `status_string`
			FROM
			  `օbject_table` 
			WHERE `օbject_table`.`object_id` = {$objectID} AND `օbject_table`.`enable` = 1"; 
	$res = $db->query($sql,1);
	if( $res === false ) {
		$error = $GLOBALS['error'];
		die( $error->getUserMessage() );
	}
	$tables = $res;
}
$TABLES = "";
$tableTims = array();
foreach ( $tables as $table ) {
$tableTims[(string)$table['id']] ['status'] = ($table['status'] == 0) ? false : true; 
$tableTims[(string)$table['id']] ['time'] = $table['time'];
$TABLES .= <<<EOF
		<li class="span3"><a class="thumbnail">
				<div id="box_{$table['id']}" class="box-{$table['status_string']}">
					<span id="{$table['id']}" onclick="selectTable(event);" class="table-{$table['status_string']}"><img
						src="http://project.tk/images/table/fon.png"
						style="width: 210px; height: 180px;">
						<div
							style="position: absolute; margin: auto auto; top: 0; left: 0; width: 210px; height: 180px;">
							<h1 class="number">{$table['name']}</h1>
							<h3 id="time_{$table['id']}" class="time"></h3>
						</div> </span>
				</div>
		</a></li>
EOF;
}
$tableTimsString = json_encode($tableTims);
$head = <<<EOF
  <script>
  	var tableTims = {$tableTimsString} ;
  </script>
  <link type="text/css" href="{$SITE}/template/admin/css/tables_manager.css" rel="stylesheet">
  <script src="{$SITE}/js/jquery/jquery.animate-shadow-min.js"></script>
  <script src="{$SITE}/js/admin/tables_manager.js"></script>
EOF;
$HEADER = $head;

/*
$body = <<<BODY
<br>
<br>
	<ul class="thumbnails">
		<li class="span3"><a class="thumbnail" style="text-decoration: none;">
				<div id="box_1" class="box-free">
					<span id="1" onclick="selectTable(event);" class="table-free"><img
						src="http://project.tk/images/table/fon.png"
						style="width: 210px; height: 180px;">
						<div
							style="position: absolute; margin: auto auto; top: 0; left: 0; width: 210px; height: 180px;">
							<h1 class="number">N 1</h1>
							<h3 id="time_1" class="time"></h3>
							<span class="label label-warning waitTime4">10:30</span>
					<!-- 	<span class="label label-warning waitTime3">14:30</span>
							<span class="label label-warning waitTime2">19:30</span>
							<span class="label label-warning waitTime1">21:00</span>
				 -->		</div> </span>
				</div>
		</a></li>
		<li class="span3"><a href="#" class="thumbnail">
				<div id="box_2" class="box-free">
					<span id="2" onclick="selectTable(event);" class="table-free"><img
						src="http://project.tk/images/table/fon.png"
						style="width: 210px; height: 180px;">
						<div
							style="position: absolute; margin: auto auto; top: 0; left: 0; width: 210px; height: 180px;">
							<h1 class="number">N 2</h1>
							<h3 id="time_2" class="time"></h3>
						</div> </span>
				</div>
		</a></li>
		<li class="span3"><a href="#" class="thumbnail">
				<div id="box_3" class="box-free">
					<span id="3" onclick="selectTable(event);" class="table-free"><img
						src="http://project.tk/images/table/fon.png"
						style="width: 210px; height: 180px;">
						<div
							style="position: absolute; margin: auto auto; top: 0; left: 0; width: 210px; height: 180px;">
							<h1 class="number">N 3</h1>
							<h3 id="time_3" class="time"></h3>
						</div> </span>
				</div>
		</a></li>
		<li class="span3"><a href="#" class="thumbnail">
				<div id="box_4" class="box-free">
					<span id="4" onclick="selectTable(event);" class="table-free"><img
						src="http://project.tk/images/table/fon.png"
						style="width: 210px; height: 180px;">
						<div
							style="position: absolute; margin: auto auto; top: 0; left: 0; width: 210px; height: 180px;">
							<h1 class="number">N 4</h1>
							<h3 id="time_4" class="time"></h3>
						</div> </span>
				</div>
		</a></li>
	</ul>
BODY;
$BODY = $body;
*/

$body = <<<BODY
<br>
<br>
	<ul class="thumbnails">
{$TABLES}
	</ul>
BODY;
$BODY = $body;

?>